package com.bmps.springcloud.insuredmicroservice.callback.accept;

import com.bmps.springcloud.common.response.CloudPlatModel;
import com.bmps.springcloud.common.response.TaskResponseModel;
import com.bmps.springcloud.common.task.bean.RequestObject;
import com.bmps.springcloud.insuredmicroservice.service.cloudplatform.RiskSupport;
import java.util.concurrent.Callable;

/**
 * 保盾云任务
 * @author lyw
 * @date 2019-09-24 18:09:29
 */
public class CloudPlatCallBack implements Callable<TaskResponseModel> {
    private String key;
    private RequestObject requestObject;
    private final RiskSupport riskSupport;

    public CloudPlatCallBack(String key, RiskSupport riskSupport, RequestObject requestObject) {
        this.setKey(key);
        this.riskSupport = riskSupport;
        this.setRequestObject(requestObject);
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    private void setRequestObject(RequestObject requestObject) {
        this.requestObject = requestObject;
    }

    /**
     * Computes a result, or throws an exception if unable to do so.
     *
     * @return computed result
     */
    @Override
    @SuppressWarnings("unchecked")
    public TaskResponseModel call() {
        return riskSupport.riskInvokeOld(key, (CloudPlatModel) requestObject.getParams());
    }
}
